<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateMessagesTable extends Migration
{
    /**
     * Run the migrations.
     * @return void
     */
    public function up()
    {
        Schema::create('messages', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('sender_id')->default(0);
            $table->text('receiver_ids')->nullable();
            $table->string('title', 100)->default('');
            $table->text('content')->nullable();
            $table->string('file1', 100)->default('');
            $table->tinyInteger('send_status')->default(0);
            $table->dateTime('created_at')->nullable();
            $table->dateTime('updated_at')->nullable();
        });

        Schema::create('message_status', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('message_id')->default(0);
            $table->unsignedInteger('sender_id')->default(0);
            $table->unsignedInteger('receiver_id')->default(0);
            $table->tinyInteger('view_status')->default(0);
            $table->tinyInteger('status')->default(0);
            $table->dateTime('created_at')->nullable();
            $table->dateTime('updated_at')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     * @return void
     */
    public function down()
    {
        Schema::drop('message_status');
        Schema::drop('messages');
    }
}
